<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8" />
    <title>审核资源_资源共享平台</title>
    <link rel="stylesheet" href="/layui/css/layui.css"/>
</head>
<body>
<div style="padding: 20px">
   	<span class="layui-breadcrumb">
        <a>首页</a>
        <a>资源管理</a>
        <a><cite>资源审核</cite></a>
	</span>
    <div style="padding-top: 20px;">
        <table class="layui-table">
            <tr>
                <td>资源名称：</td>
                <td th:text="${res.name}"></td>
            </tr>
            <tr>
                <td>资源类别：</td>
                <td th:text="${res.resType.name}"></td>
            </tr>
            <tr>
                <td valign="top">资源描述：</td>
                <td th:utext="${res.content}"></td>
            </tr>
            <tr>
                <td valign="top">分享资源：</td>
                <td>
                    <a target="_blank" th:href="${res.downloadUrl}" th:text="${res.downloadUrl}"></a>
                    密码：<label style="color: red;" th:text="${res.downloadPass}"></label>
                </td>
            </tr>
            <tr>
                <td>积分设置：</td>
                <td th:text="${res.points}"></td>
            </tr>
            <tr>
                <td valign="top">审核未通过原因：</td>
                <td>
                    <textarea id="reason" style="width: 400px;height: 80px;" placeholder="如果审核未通过，请填写未通过原因"></textarea>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <button class="layui-btn" onclick="yes()">审核通过</button>
                    <button class="layui-btn layui-btn-danger" onclick="no()" style="margin-left: 20px;">驳回</button>
                </td>
            </tr>
        </table>
    </div>
</div>

<script src="/layui/layui.js"></script>
<script src="/js/common.js"></script>
<script type="text/javascript" th:inline="javascript">
    /*<![CDATA[*/
    let $, layer;
    layui.use(['layer'], function () {
        $ = layui.jquery,
            layer = layui.layer
    });
    function yes() {
        $.post("/admin/res/updateStatus", {
            id: [[${res.id}]],
            checkStatus: 2
        }, function (result) {
            if (result.success) {
                layer.alert("执行成功！", function () {
                    history.back();
                });
            } else {
                layer.msg("执行失败，请联系管理员！");
            }
        }, "json");
    }

    function no() {
        if ($("#reason").val() == "") {
            layer.msg("请输入驳回理由！");
            $("#reason").focus();
            return;
        }
        $.post("/admin/res/updateStatus", {
            id: [[${res.id}]],
            checkStatus: 3,
            reason: $("#reason").val()
        }, function (result) {
            if (result.success) {
                layer.alert("执行成功！", function () {
                    history.back();
                });
            } else {
                layer.msg("执行失败，请联系管理员！");
            }
        }, "json");
    }
    /*]]>*/
</script>
</body>
</html>